import React,{PureComponent} from 'react'
class App extends PureComponent{
    constructor(){
        super()
        // 修正this指向方式1
        this.handClick=this.handClick.bind(this)
    }
    handClick(){
        console.log(this)
    }
    handClick1(){
        console.log(this)
    }
    handClick2=()=>{
        console.log(this)
    }
    render(){
        return(
            <React.Fragment>
                <button onClick={this.handClick}>修正this指向方式1</button>
                {/* 修正this指向方式2 */}
                <button onClick={this.handClick1.bind(this)}>修正this指向方式2</button>
                <button onClick={this.handClick2}>修正this指向方式3</button>
            </React.Fragment>
        )
    }
}
export default App